﻿#region

using System.Collections.Generic;
using BusinessObjects;
using DataAccessLayer;

#endregion

namespace BusinessLogicLayer
{
    public static class StaffBLL
    {
        /// <summary>
        ///     Register a staff
        /// </summary>
        /// <param name="firstName">Represent's the staff's first name</param>
        /// <param name="lastName">Represent's the staff's last name</param>
        /// <param name="eMail">Represent's the staff's e-mail</param>
        /// <param name="telephone">Represent's the staff's telephone</param>
        /// <param name="address">Represent's the staff's address</param>
        /// <param name="type">Represent's the staff type</param>
        /// <param name="subsidiaryId">Represent's the subsidiary id</param>
        /// <returns>Staff Id</returns>
        public static int RegisterStaff(string firstName, string lastName, string eMail, string telephone,
            string address, string type, byte? subsidiaryId)
        {
            var staff = new Staff
            {
                FirstName = firstName.Trim(),
                LastName = lastName.Trim(),
                EMail = eMail.Trim(),
                TelephoneNo = telephone.Trim(),
                Address = address.Trim().ToLower(),
                Type = type.Trim(),
                SubsidiaryId = subsidiaryId
            };

            return StaffDAL.RegisterStaff(staff);
        }

        /// <summary>
        ///     Check whether the email is taken or not
        /// </summary>
        /// <param name="eMail">Represent's the staff's email</param>
        /// <returns>Taken or not</returns>
        public static bool IsEMailTaken(string eMail)
        {
            return StaffDAL.IsEMailTaken(eMail.Trim());
        }

        /// <summary>
        ///     Get All staffs
        /// </summary>
        /// <returns>All staffs</returns>
        public static List<Staff> GetAllStaffs()
        {
            return StaffDAL.GetAllStaffs();
        }

        /// <summary>
        ///     Get staff by id
        /// </summary>
        /// <returns>Staff</returns>
        public static Staff GetStaffById(int staffId)
        {
            return StaffDAL.GetStaffById(staffId);
        }

        /// <summary>
        ///     Edit staff details
        /// </summary>
        /// <param name="staffId">Represent's the staff's id</param>
        /// <param name="firstName">Represent's the staff's first name</param>
        /// <param name="lastName">Represent's the staff's last name</param>
        /// <param name="eMail">Represent's the staff's e-mail</param>
        /// <param name="telephone">Represent's the staff's telephone</param>
        /// <param name="address">Represent's the staff's address</param>
        /// <param name="type">Represent's the staff type</param>
        /// <param name="subsidiaryId">Represent's the subsidiary id</param>
        public static void EditStaff(int staffId, string firstName, string lastName, string eMail, string telephone,
            string address, string type, byte? subsidiaryId)
        {
            var staff = new Staff
            {
                StaffId = staffId,
                FirstName = firstName.Trim(),
                LastName = lastName.Trim(),
                EMail = eMail.Trim(),
                TelephoneNo = telephone.Trim(),
                Address = address.Trim().ToLower(),
                Type = type.Trim(),
                SubsidiaryId = subsidiaryId
            };

            StaffDAL.EditStaff(staff);
        }

        /// <summary>
        ///     Remove a staff
        /// </summary>
        /// <param name="staffId">Represent's the staff id</param>
        public static void RemoveStaff(int staffId)
        {
            StaffDAL.RemoveStaff(staffId);
        }
    }
}